import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
plt.rcParams['axes.unicode_minus'] = False

inner_radius = 0.9
outer_radius = 1
num_segments = 14

inner_colors = ['#F7C1D0', '#F7C1D0', '#ADD9EE', '#ADD9EE', '#ADD9EE', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#CAC0E1', '#CAC0E1', '#CAC0E1', '#F7C1DB', '#F7C1DC']

outer_colors = ['#FFD47E' for _ in range(num_segments)]

fig, ax = plt.subplots()

wedges1, texts1 = ax.pie([1] * num_segments, radius=inner_radius, colors=inner_colors, startangle=90, counterclock=False, wedgeprops=dict(width=0.3, edgecolor='w'))

wedges2, texts2 = ax.pie([1] * num_segments, radius=outer_radius, colors=outer_colors, startangle=90, counterclock=False, wedgeprops=dict(width=0.3, edgecolor='w'))

labels = []
label_value = 70
for color in inner_colors:
    if color != '#FFFFFF':
        labels.append(label_value)
        label_value += 10
    else:
        labels.append(None)

for i, wedge in enumerate(wedges1):
    if labels[i] is not None:
        angle = (wedge.theta2 - wedge.theta1) / 2 + wedge.theta1
        x_left = (inner_radius - 0.05) * np.cos(np.deg2rad(angle - 5))
        y_left = (inner_radius + 0.05) * np.sin(np.deg2rad(angle - 5))
        x_right = (inner_radius + 0.05) * np.cos(np.deg2rad(angle + 5))
        y_right = (inner_radius + 0.05) * np.sin(np.deg2rad(angle + 5))

        ax.text(x_left, y_left, str(labels[i]), ha='center', va='center', color='black')

        ax.text(x_right, y_right, str(labels[i]), ha='center', va='center', color='black')

ax.set_aspect('equal')
plt.title('仪表盘图')

#plt.savefig('D:/python charm/01/可视化/第二章/图片/仪表盘图.png')

# 显示图表
plt.show()